home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / midas060 / src / errors.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-16  |  9.4 KB  |  280 lines

  1. /*      errors.h
  2.  *
  3.  * MIDAS Sound System error codes and error message strings
  4.  *
  5.  * $Id: errors.h,v 1.6 1996/10/20 20:53:36 pekangas Exp $
  6.  *
  7.  * Copyright 1996 Petteri Kangaslampi and Jarno Paananen
  8.  *
  9.  * This file is part of the MIDAS Sound System, and may only be
  10.  * used, modified and distributed under the terms of the MIDAS
  11.  * Sound System license, LICENSE.TXT. By continuing to use,
  12.  * modify or distribute this file you indicate that you have
  13.  * read the license and understand and accept it fully.
  14. */
  15.  
  16.  
  17. #ifndef __errors_h
  18. #define __errors_h
  19.  
  20.  
  21. #define MAXERRORS 256       /* maximum number of errors to store */
  22.  
  23.  
  24. /****************************************************************************\
  25. *       enum ErrorCodes
  26. *       ---------------
  27. * Description:  MIDAS Sound System error codes
  28. \****************************************************************************/
  29.  
  30. enum ErrorCodes
  31. {
  32.     OK = 0,                             /* no error */
  33.     errUndefined,                       /* undefined error */
  34.     errOutOfMemory,                     /* out of (conventional) memory */
  35.     errHeapCorrupted,                   /* (conventional memory) heap
  36.                                            corrupted */
  37.     errInvalidBlock,                    /* invalid memory block */
  38.     errOutOfEMS,                        /* out of EMS memory */
  39.     errEMSHeapCorrupted,                /* EMS heap corrupted */
  40.     errInvalidEMSBlock,                 /* invalid EMS memory block */
  41.     errEMMFailure,                      /* Expanded Memory Manager failure */
  42.     errOutOfCardMemory,                 /* out of soundcard memory */
  43.     errCardHeapCorrupted,               /* soundcard heap corrupted */
  44.     errInvalidCardBlock,                /* invalid soundcard memory block */
  45.     errNoSampleHandles,                 /* out of sample handles */
  46.     errFileOpen,                        /* unable to open file */
  47.     errFileRead,                        /* unable to read file */
  48.     errInvalidModule,                   /* invalid module file */
  49.     errInvalidInst,                     /* invalid instrument in module */
  50.     errInvalidPatt,                     /* invalid pattern data in module */
  51.     errInvalidChanNumber,               /* invalid channel number */
  52.     errInvalidSampleHandle,             /* invalid sample handle */
  53.     errNoChannels,                      /* Sound Device channels not open */
  54.     errSDFailure,                       /* Sound Device hardware failure */
  55.     errInvalidArguments,                /* invalid function arguments */
  56.     errFileNotFound,                    /* file does not exist */
  57.     errInvalidFileHandle,               /* invalid file handle */
  58.     errAccessDenied,                    /* access denied */
  59.     errFileExists,                      /* file exists */
  60.     errTooManyFiles,                    /* too many open files */
  61.     errDiskFull,                        /* disk full */
  62.     errEndOfFile,                       /* unexpected end of file */
  63.     errInvalidPath,                     /* invalid path */
  64.     errFileWrite,                       /* unable to write file */
  65.     errVDSLock,                         /* unable to lock VDS DMA buffer */
  66.     errVDSUsage,                        /* unable to use Virtual DMA */
  67.     errBadVDS,                          /* invalid VDS version */
  68.     errDPMIFailure,                     /* DPMI failure */
  69.     errInvalidDescriptor,               /* invalid segment descriptor */
  70.     errOutOfResources,                  /* out of system resources */
  71.     errInvalidDevice,                   /* invalid device used */
  72.     errUnsupported,                     /* unsupported function used */
  73.     errDeviceNotAvailable,              /* device not available */
  74.     errDeviceBusy,                      /* device is busy */
  75.     errBadMode,                         /* unsupported output mode used */
  76.     errUnableToLock,                    /* unable to lock memory */
  77.     errNumErrorCodes
  78. };
  79.  
  80.  
  81.  
  82. /****************************************************************************\
  83. *       enum FunctionIDs
  84. *       ----------------
  85. * Description:  ID numbers for first functions in all modules
  86. \****************************************************************************/
  87.  
  88. enum FunctionIDs
  89. {
  90.     ID_error = 0,                       /* error handling */
  91.     ID_dma = 100,                       /* DMA handling routines */
  92.     ID_dsm = 200,                       /* Digital Sound Mixer */
  93.     ID_ems = 300,                       /* EMS heap manager */
  94.     ID_mem = 400,                       /* Conventional memory management */
  95.     ID_mod = 500,                       /* Protracker Module Player */
  96.     ID_s3m = 600,                       /* Scream Tracker 3 Module Player */
  97.     ID_mtm = 700,                       /* Multitracker Module Player */
  98.     ID_tmr = 1000,                      /* TempoTimer */
  99.     ID_vu = 1100,                       /* Real VU meters */
  100.     ID_rf = 1200,                       /* Raw file I/O */
  101.     ID_file = 1300,                     /* High-level file I/O */
  102.     ID_dpmi = 1400,                     /* DPMI functions */
  103.     ID_gmp = 1500,                      /* Generic Module Player */
  104.     ID_fx = 1600,                       /* Sound effects library */
  105.     ID_str = 1700,                      /* Stream library */
  106.     ID_gus = 2000,                      /* GUS Sound Device */
  107.     ID_pas = 2100,                      /* PAS Sound Device */
  108.     ID_wss = 2200,                      /* WSS Sound Device */
  109.     ID_sb = 2300,                       /* SB Sound Device */
  110.     ID_winw = 2400,                     /* Windows Wave Sound Device */
  111.     ID_oss = 2500,                      /* OSS Sound Device */
  112.     ID_gdc = 2600,                      /* GUS Mixing Sound Device */
  113.     ID_awe = 2700,                      /* AWE32 Sound Device */
  114.     ID_nsnd = 2900,                     /* No Sound Sound Device */
  115.     ID_mixsd = 3000                     /* Common mixing Sound Device
  116.                                            functions */
  117. };
  118.  
  119.  
  120.  
  121. #ifdef __cplusplus
  122. extern "C" {
  123. #endif
  124.  
  125.  
  126. #ifdef DEBUG
  127.  
  128. /****************************************************************************\
  129. *       struct errRecord
  130. *       ----------------
  131. * Description:  Error record for error list
  132. \****************************************************************************/
  133.  
  134. typedef struct
  135. {
  136.     int         errorCode;              /* error code number */
  137.     unsigned    functID;                /* ID for function that caused the
  138.                                            error */
  139. } errRecord;
  140.  
  141.  
  142. extern errRecord GLOBALVAR  errorList[MAXERRORS];       /* error list */
  143. extern unsigned GLOBALVAR   numErrors;  /* number of errors in list */
  144.  
  145.  
  146.  
  147. /****************************************************************************\
  148. *
  149. * Function:     void errAdd(int errorCode, unsigned functID);
  150. *
  151. * Description:  Add an error to error list
  152. *
  153. * Input:        int errorCode           error code
  154. *               unsigned functID        ID for function that caused the error
  155. *
  156. \****************************************************************************/
  157.  
  158. void CALLING errAdd(int errorCode, unsigned functID);
  159.  
  160.  
  161.  
  162.  
  163. /****************************************************************************\
  164. *
  165. * Function:     void errClearList(void)
  166. *
  167. * Description:  Clears the error list. Can be called if a error has been
  168. *               handled without exiting the program to avoid filling the
  169. *               error list with handled errors.
  170. *
  171. \****************************************************************************/
  172.  
  173. void CALLING errClearList(void);
  174.  
  175.  
  176.  
  177.  
  178. /****************************************************************************\
  179. *
  180. * Function:     void errPrintList(void);
  181. *
  182. * Description:  Prints the error list to stderr
  183. *
  184. \****************************************************************************/
  185.  
  186. void CALLING errPrintList(void);
  187.  
  188.  
  189. #endif
  190.  
  191.  
  192.  
  193.  
  194. /****************************************************************************\
  195. *
  196. * Function:     void errErrorExit(char *msg)
  197. *
  198. * Description:  Set up standard text mode, print an error message and exit
  199. *
  200. * Input:        char *msg               pointer to error message, ASCIIZ
  201. *
  202. \****************************************************************************/
  203.  
  204. void CALLING errErrorExit(char *msg);
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211. /* error message string pointers: */
  212. extern char * GLOBALVAR errorMsg[errNumErrorCodes];
  213.  
  214.  
  215. #ifdef __cplusplus
  216. }
  217. #endif
  218.  
  219.  
  220.  
  221.  
  222. //win-
  223. #ifdef ERROR
  224. #undef ERROR
  225. #endif
  226.  
  227.  
  228. /* ERROR - adds an error to the MIDAS error list if DEBUG is defined.
  229.    Does nothing otherwise. */
  230.  
  231. #ifdef DEBUG
  232.     #define ERROR(errCode, functID) errAdd(errCode, functID)
  233. #else
  234.     #define ERROR(errCode, functID)
  235. #endif
  236.  
  237.  
  238. /* PASSERROR - passes error value in variable error on */
  239.  
  240. #ifdef DEBUG
  241.     #define PASSERROR(functID) { errAdd(error, functID); return error; }
  242. #else
  243.     #define PASSERROR(functID) return error;
  244. #endif
  245.  
  246.  
  247.  
  248. /* CLEARERRORLIST - clear the MIDAS error list if DEBUG is defined. */
  249. #ifdef DEBUG
  250.     #define CLEARERRORLIST errClearList();
  251. #else
  252.     #define CLEARERRORLIST ;
  253. #endif
  254.  
  255.  
  256.  
  257. #endif  /* #ifndef __errors_h */
  258.  
  259.  
  260. /*
  261.  * $Log: errors.h,v $
  262.  * Revision 1.6  1996/10/20 20:53:36  pekangas
  263.  * Added AWE32 Sound Device ID
  264.  *
  265.  * Revision 1.5  1996/09/22 23:15:33  pekangas
  266.  * Added ID_fx and ID_str
  267.  *
  268.  * Revision 1.4  1996/09/21 16:38:00  jpaana
  269.  * Changed uss to oss
  270.  *
  271.  * Revision 1.3  1996/06/05 19:40:35  jpaana
  272.  * Changed usswave to uss
  273.  *
  274.  * Revision 1.2  1996/05/24 20:40:12  jpaana
  275.  * Added USSWave
  276.  *
  277.  * Revision 1.1  1996/05/22 20:49:33  pekangas
  278.  * Initial revision
  279.  *
  280. */